<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改订单')" />
</head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content" th:object="${jtOrder}">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>交易信息 <small class="m-l-sm"></small></h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-xs-4">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">[[#{orderNo}]]：</label>
                                <div class="col-sm-8">
                                    <span th:text="*{orderNo}"></span>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">[[#{buyer}]]：</label>
                                <div class="col-sm-8">
                                    <span th:text="*{buyer}"></span>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">[[#{orderPlacingTime}]]：</label>
                                <div class="col-sm-8">
                                    <span th:text="*{createTime}"></span>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">[[#{paymentTime}]]：</label>
                                <div class="col-sm-8">
                                    <span th:text="*{paymentTime}"></span>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">[[#{logisticsCompany}]]：</label>
                                <div class="col-sm-8">
                                    <span th:text="*{logisticsCompany}"></span>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">[[#{trackingNo}]]：</label>
                                <div class="col-sm-8">
                                    <span th:text="*{trackingNumber}"></span>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>备注信息 <small class="m-l-sm"></small></h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">[[#{buyerRemark}]]：</label>
                                <div class="col-sm-8">
                                    <input name="buyerRemark" th:field="*{buyerRemark}" class="form-control" type="text">
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-12">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">[[#{sellerRemark}]]：</label>
                                <div class="col-sm-8">
                                    <input name="sellerRemark" th:field="*{sellerRemark}" class="form-control" type="text">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-title">
                    <h5>收货地址信息 <small class="m-l-sm"></small></h5>
                    <div class="ibox-tools">
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                    </div>
                </div>
                <div class="ibox-content">
                    <div class="row">
                        <div class="col-xs-4">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">[[#{receiver}]]：</label>
                                <div class="col-sm-8">
                                    <input name="receiver" th:field="*{receiver}" class="form-control" type="text">
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">[[#{phoneNumber}]]：</label>
                                <div class="col-sm-8">
                                    <input name="phoneNumber" th:field="*{phoneNumber}" class="form-control" type="text">
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">[[#{region}]]：</label>
                                <div class="col-sm-8">
                                    <input name="country" th:field="*{country}" class="form-control" type="text">
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">[[#{province}]]：</label>
                                <div class="col-sm-8">
                                    <input name="province" th:field="*{province}" class="form-control" type="text">
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">[[#{city}]]：</label>
                                <div class="col-sm-8">
                                    <input name="city" th:field="*{city}" class="form-control" type="text">
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-4">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">[[#{district}]]：</label>
                                <div class="col-sm-8">
                                    <input name="district" th:field="*{district}" class="form-control" type="text">
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-6">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">[[#{detailedAddress}]]：</label>
                                <div class="col-sm-8">
                                    <input name="fullAddress" th:field="*{fullAddress}" class="form-control" type="text">
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-6">
                            <div class="form-group">
                                <label class="col-sm-3 control-label">[[#{zipCode}]]：</label>
                                <div class="col-sm-8">
                                    <input name="postCode" th:field="*{zipCode}" class="form-control" type="text">
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>


        <h4 class="form-header h4">订单明细信息</h4>
        <div class="row">
            <div class="col-sm-12">
                <div class="col-sm-12 select-table table-striped">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
        <div class="row">
            <div class="col-xs-8"></div>
            <div class="col-xs-4">
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">[[#{buyQty}]]：</label>
                        <div class="col-sm-6">
                            <span th:text="*{buyQty}"></span>
                        </div>
                    </div>
                </div>
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">[[#{currency}]]：</label>
                        <div class="col-sm-6">
                            <span th:text="*{currency}"></span>
                        </div>
                    </div>
                </div>
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">[[#{shippingFee}]]：</label>
                        <div class="col-sm-6">
                            <span th:text="*{freightAmount}"></span>
                        </div>
                    </div>
                </div>
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">[[#{discounts}]]：</label>
                        <div class="col-sm-6">
                            <span th:text="*{reduceAmount}"></span>
                        </div>
                    </div>
                </div>
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">订单金额：</label>
                        <div class="col-sm-6">
                            <span th:text="*{orderAmount}"></span>
                        </div>
                    </div>
                </div>
                <div class="col-xs-12">
                    <div class="form-group">
                        <label class="col-sm-4 control-label">[[#{paymentAmount}]]：</label>
                        <div class="col-sm-6">
                            <span th:text="*{paymentAmount}"></span>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <script th:inline="javascript">
        var prefix = ctx + "business/order";
        $("#form-order-edit").validate({
            focusCleanup: true
        });

        function submitHandler() {
            if ($.validate.form()) {
                $.operate.save(prefix + "/edit", $('#form-order-edit').serialize());
            }
        }

        $(function() {
            var options = {
                data: [[${jtOrder.jtOrderItemList}]],
                pagination: false,
                showSearch: false,
                showRefresh: false,
                showToggle: false,
                showColumns: false,
                sidePagination: "client",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'index',
                    align: 'center',
                    title: i18n('serialNumber'),
                    formatter: function (value, row, index) {
                    	var columnIndex = $.common.sprintf("<input type='hidden' name='index' value='%s'>", $.table.serialNumber(index));
                    	return columnIndex + $.table.serialNumber(index);
                    }
                },
                {
                    field: 'imageUrl',
                    align: 'center',
                    title: i18n("image"),
                    formatter: function(value, row, index) {
                        var imageUrl = value;
                        if(ctx.length > 1 && imageUrl != ""){
                            if(imageUrl.indexOf("/") == 0){
                                imageUrl = ctx + imageUrl.substr(1);
                            } else {
                                imageUrl = ctx + imageUrl;
                            }
                        }
                        return imageLazyLoadView(imageUrl, "auto", 750);
                    }
                },
                {
                    field: 'prodName',
                    align: 'center',
                    title: i18n("productName"),
                    formatter: function(value, row, index) {

                        var html = $.common.sprintf("<div><span>%s</span> &nbsp;<span>%s</span> </div>",row.skuCode ,row.styleNo);
                        return value + html;
                    }
                },
                {
                    field: 'skuName',
                    align: 'center',
                    title: i18n('productName')
                },
                {
                    field: 'price',
                    align: 'center',
                    title: i18n("unitPrice")
                },
                {
                    field: 'prodCount',
                    align: 'center',
                    title: i18n("quantity")
                },
                {
                    field: 'totalAmount',
                    align: 'center',
                    title: i18n("totalAmount")
                },
                {
                    title: i18n('op'),
                    align: 'center',
                    formatter: function(value, row, index) {
                        var value = $.common.isNotEmpty(row.index) ? row.index : $.table.serialNumber(index);
                        return '<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="sub.delRowByIndex(\'' + value + '\')"><i class="fa fa-remove"></i>删除</a>';
                    }
                }]
            };
            $.table.init(options);
        });

        function addRow() {
            var count = $("#" + table.options.id).bootstrapTable('getData').length;
            var row = {
                index: $.table.serialNumber(count),
                productId: "",
                skuId: "",
                prodName: "",
                skuName: "",
                price: "",
                prodCount: "",
                totalAmount: "",
                createBy: "",
                createTime: "",
                updateBy: "",
                updateTime: "",
            }
            sub.addRow(row);
        }

        // 图片预览
        function imageLazyLoadView(value, height, width, target) {
            if ($.common.isEmpty(width)) {
                width = 'auto';
            }
            if ($.common.isEmpty(height)) {
                height = 'auto';
            }
            if($.common.isMobile()){
                target = "blank";
            }
            var windowWidth = $(window).width();
            //console.log("imgW====="+windowWidth)
            var imgW = 'img-md';
            if(windowWidth < 1024){
                imgW = 'img-lg';
            }
            // blank or self
            var _target = $.common.isEmpty(target) ? 'self' : target;
            if ($.common.isNotEmpty(value)) {
                return $.common.sprintf("<img class='img-circle "+imgW+" lazyload' data-type='2' data-height='%s' data-width='%s' data-target='%s' src='%s' />", height, width, _target, value);
            } else {
                return $.common.nullToStr(value);
            }
        }
    </script>
    <script>
        $(".modal").appendTo("body"), $("[data-toggle=popover]").popover(), $(".collapse-link").click(function() {
            var div_ibox = $(this).closest("div.ibox"),
                e = $(this).find("i"),
                i = div_ibox.find("div.ibox-content");
            i.slideToggle(200),
                e.toggleClass("fa-chevron-up").toggleClass("fa-chevron-down"),
                div_ibox.toggleClass("").toggleClass("border-bottom"),
                setTimeout(function() {
                    div_ibox.resize();
                }, 50);
        }), $(".close-link").click(function () {
            var div_ibox = $(this).closest("div.ibox");
            div_ibox.remove()
        });
    </script>
    <script th:inline="javascript">
        var ROOT = [[${#servletContext.contextPath}]];
        var LANG_COUNTRY = [[${#locale.language+'_'+#locale.country}]];

        //初始化i18n插件
        $.i18n.properties({
            path: ROOT + '/i18n/',//这里表示访问路径
            name: 'messages',//文件名开头
            language: LANG_COUNTRY,//文件名语言 例如en_US
            mode: 'map'//默认值
        });

        function i18n(msgKey) {
            try {
                return $.i18n.prop(msgKey);
            } catch (e) {
                return msgKey;
            }
        }
    </script>
</body>
</html>